﻿@using Isaac.Joy.Identity.Module
@using Isaac.Joy.WebHelper
@model Isaac.Joy.Identity.Web.DtCms.Models.UserViewModel
@{
    Layout = null;
    var genders = EnumExtentions.ToCollection<Gender>();
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>编辑用户</title>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/jquery-1.10.2.min.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/Validform_v5.3.2.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/lhgdialog/lhgdialog.js?skin=idialog")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/datepicker/WdatePicker.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/layout.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/json2.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/errorCode.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/jqueryStatic.js")"></script>
    <link type="text/css" href="@Url.BundleContent("~/css/style.css")" rel="stylesheet" />
    <script type="text/javascript">
        $(function () {
            var mainform = $("#mainform").Validform({ tiptype: dtcmstiptype, showAllError: true });

            $("#btnSubmit").click(function () {
                if (!mainform.check()) return false;

                $.ajax({
                    url: '@Url.Action("AjaxAdd")',
                    type: "post",
                    data: "User.Account=" + $("#txtAccount").val() +
                        "&User.Password=" + $("#txtPassword").val() +
                        "&User.Email=" + $("#txtEmail").val() +
                        "&User.NickName=" + $("#txtNickName").val() +
                        "&User.Gender=" + $('input:radio[name=rblGender]:checked').val() +
                        "&User.Birthday=" + $("#txtBirthday").val() +
                        "&User.Mobile=" + $("#txtMobile").val() +
                        "&User.Tel=" + $("#txtTel").val() +
                        "&User.QQ=" + $("#txtQQ").val() +
                        "&User.Address=" + $("#txtAddress").val() +
                        "&User.Role.Id=" + $("#ddlRole").val() +
                        "",
                    processData: false,
                    success: function (response) {
                        var data = JSON.parse(response);
                        errorCode.getMsg(data, function () {
                            if (data.success) {
                                $.dialog.alert('添加成功！', function () {
                                    document.location.reload();
                                }, null, "提示");
                            } else {
                                $.dialog.alert('添加失败！');
                            }
                        }, function (e) {
                            $.dialog.alert(data.msg == '' ? e.msg : data.msg);
                        });
                        return false;
                    }
                });
                return false;
            });
        });
    </script>
</head>

<body class="mainbody">
    <div id="mainform">
        <!--导航栏-->
        <div class="location">
            <a href="user_list.aspx" class="back"><i></i><span>返回列表页</span></a>
            <a href="../center.aspx" class="home"><i></i><span>首页</span></a>
            <i class="arrow"></i>
            <span>会员管理</span>
            <i class="arrow"></i>
            <span>编辑用户</span>
        </div>
        <div class="line10"></div>
        <!--/导航栏-->

        <!--内容-->
        <div class="content-tab-wrap">
            <div id="floatHead" class="content-tab">
                <div class="content-tab-ul-wrap">
                    <ul>
                        <li><a href="javascript:;" onclick="tabs(this);" class="selected">基本资料</a></li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="tab-content">
            <dl>
                <dt>用户角色</dt>
                <dd>
                    <div class="rule-single-select">
                        <select name="ddlRole" id="ddlRole" datatype="*" errormsg="请选择角色" sucmsg=" ">
                            <option value="">请选择角色...</option>
                            @foreach (var role in Model.Roles)
                            {
                                <option value="@role.Id">@role.Name</option>
                            }
                        </select>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>用户名</dt>
                <dd>
                    <input type="text" id="txtAccount" class="input normal" datatype="*2-200" sucmsg=" " />
                    <span class="Validform_checktip">*登录的用户名，支持中文</span>
                </dd>
            </dl>
            <dl>
                <dt>登录密码</dt>
                <dd>
                    <input type="password" id="txtPassword" name="txtPassword" class="input normal" datatype="*6-20" nullmsg="请设置密码" errormsg="密码范围在6-20位之间" sucmsg=" " />
                    <span class="Validform_checktip">*登录的密码，至少6位</span></dd>
            </dl>
            <dl>
                <dt>确认密码</dt>
                <dd>
                    <input type="password" id="txtPassword2" class="input normal" datatype="*" recheck="txtPassword" nullmsg="请再输入一次密码" errormsg="两次输入的密码不一致" sucmsg=" " />
                    <span class="Validform_checktip">*再次输入密码</span></dd>
            </dl>
            <dl>
                <dt>邮箱账号</dt>
                <dd>
                    <input type="text" id="txtEmail" class="input normal" datatype="e" ignore="ignore" sucmsg=" " />
                    <span class="Validform_checktip">*取回密码时用到</span></dd>
            </dl>
            <dl>
                <dt>用户昵称</dt>
                <dd>
                    <input type="text" id="txtNickName" class="input normal" />
                </dd>
            </dl>
            <dl>
                <dt>用户性别</dt>
                <dd>
                    <div class="rule-multi-radio">
                        <span id="rblGender">
                            @foreach (var key in genders.Keys)
                            {
                                if (Model.User.Gender.GetDisplay() == key.ToString())
                                {
                                <input id="rblGender_@genders[key.ToString()]" type="radio" name="rblGender" value="@genders[key.ToString()]" checked="checked" /><label for="rblGender_@genders[key.ToString()]">@key</label>
                                }
                                else
                                {
                                <input id="rblGender_@genders[key.ToString()]" type="radio" name="rblGender" value="@genders[key.ToString()]"/><label for="rblGender_@genders[key.ToString()]">@key</label>
                                }
                            }
                        </span>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>生日日期</dt>
                <dd>
                    <div class="input-date">
                        <input type="text" id="txtBirthday" class="input date" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" datatype="/^\s*$|^\d{4}\-\d{1,2}\-\d{1,2}$/" errormsg="请选择正确的日期" sucmsg=" " />
                        <i>日期</i>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>手机号码</dt>
                <dd>
                    <input type="text" id="txtMobile" class="input normal" />
                    <span class="Validform_checktip"></span></dd>
            </dl>
            <dl>
                <dt>电话号码</dt>
                <dd>
                    <input type="text" id="txtTel" class="input normal" /></dd>
            </dl>
            <dl>
                <dt>QQ号码</dt>
                <dd>
                    <input type="text" id="txtQQ" class="input normal" /></dd>
            </dl>
            <dl>
                <dt>通讯地址</dt>
                <dd>
                    <input type="text" id="txtAddress" class="input normal" /></dd>
            </dl>
        </div>
        <!--/内容-->

        <!--工具栏-->
        <div class="page-footer">
            <div class="btn-list">
                <input type="button" value="提交保存" id="btnSubmit" class="btn" />
                @*<input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript: history.back(-1);" />*@
            </div>
            <div class="clear"></div>
        </div>
        <!--/工具栏-->
    </div>
</body>
</html>

